﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Sockets;
using System.IO;
using System.Threading;
using GameServer.Tools;
using GameServer.Packet;
using GameServer.Events;

namespace GameServer
{

    public class Client
    {
        private TcpClient Socket;
        public String IPAddress { get; set; }
        private Thread SReader;
        private Server Server;
        private PacketHandler PHandle;

        public Client(TcpClient socket, Server server)
        {
            this.Socket = socket;
            this.Server = server;
            this.IPAddress = socket.Client.RemoteEndPoint.ToString();
            PHandle = new PacketHandler(this);
            SReader = new Thread(PHandle.StartHandling);
            SReader.Start();
            Logger.Log(LevelType.INFO, "Client connected from " + this.IPAddress);
        }

        public Server GetServer()
        {
            return this.Server;
        }

        public Stream GetStream()
        {
            return Socket.GetStream();
        }
    }
}
